<?php

/**
 * Created by PhpStorm.
 * User: evan
 * Date: 2017/3/5
 * Time: 下午6:40
 */
class Direct_seeding extends MY_Www_Controller
{
    public function index()
    {
        $limit  = 10;
        $page   = intval($this->input->get_post('page'));
        $page   = $page ? $page : 1;
        $offset = ($page - 1) * $limit;
        $cid = (int)$this->input->get_post('cid');


        $where = array();
        $cid && $where['cid'] = $cid;


        $this->load->model('direct_seeding/Model_direct_seeding', 'ds');
        $data = $this->ds->lists($offset, $limit, $where);
        $total_rows = $this->ds->count($where);
        
        $this->load->model('auction/Model_auction', 'a');
        foreach ($data as $k=>$v)
        {        
        	$auction_item = $this->a->getById($v['aid']);
        	$data[$k]['introduction'] = $auction_item['summary'];
        }

        //分页
        $this->load->library('pagination');

        $config['total_rows'] = $total_rows;
        $config['per_page'] = $limit;
        $config['base_url'] = '/Direct_seeding/index'.($cid ? '?cid='.$cid : '');

        $this->pagination->initialize($config);
        $show_page = $this->pagination->create_links();


        $this->load->model('auction/Model_auction_cate', 'ac');
        $cate_data = $this->ac->lists(OFFSET, LIMIT, array(), true, 'sort asc');


        $data = array
        (
            'cid'       => $cid,
            'data'      => $data,
            'show_page' => $show_page,
            'cate_data' => $cate_data,
        );


        $this->load->view('www/direct_seeding/index', $data);
    }
}